import { Entity, ManyToOne, JoinColumn, PrimaryColumn } from 'typeorm';
import { Role } from './role.entity';
import { Permission } from './permission.entity';

@Entity('sys_role_permission')
export class RolePermission {
    @PrimaryColumn({ comment: '角色ID' })
    roleId: number;

    @PrimaryColumn({ comment: '权限ID' })
    permId: number;

    @ManyToOne(() => Role, { onDelete: 'CASCADE' })
    @JoinColumn({ name: 'roleId' })
    role: Role;

    @ManyToOne(() => Permission, { onDelete: 'CASCADE' })
    @JoinColumn({ name: 'permId' })
    permission: Permission;
}